package com.dl.study.module.base.resinfo.service;

import com.dl.study.module.base.resinfo.dao.ResInfoDao;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoDTO;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoQueryDTO;
import com.dl.study.module.base.resinfo.domain.dto.ResInfoListQueryDTO;
import com.sca.core.common.base.PageResultDTO;
import com.sca.core.common.domain.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * [ 系统资源表 ]
 *
 * @author dl
 * @version 1.0
 * @company xxxx
 * @copyright (c) 2019 xxxxInc. All rights reserved.
 * @date 2021-10-28 16:26:17
 * @since JDK1.8
 */
@Service
public class ResInfoService {

    @Autowired
    private ResInfoDao resInfoDao;


    /**
     * @author dl
     * @description 分页查询
     * @date 2021-10-28 16:26:17
     */
    public ResponseDTO<PageResultDTO<ResInfoDTO>> queryByPage(ResInfoQueryDTO queryDTO) {
//        Page page = PaginationUtil.convert2PageQueryInfo(queryDTO);
//        ResInfoListQueryDTO listQueryDTO = BeanCopyUtil.copy(queryDTO, ResInfoListQueryDTO.class);
//        List<ResInfoDTO> dtoList = resInfoDao.queryListByCondition(page, listQueryDTO);
//        page.setRecords(dtoList);
//        PageResultDTO<ResInfoDTO> pageResultDTO = PaginationUtil.convert2PageResultDTO(page);
//        return ResponseDTO.succData(pageResultDTO);
        return null;
    }

    /**
     * @author dl
     * @description 根据条件查询列表
     * @date 2021-10-28 16:26:17
     */
    public ResponseDTO<List<ResInfoDTO>> queryListByCondition(ResInfoListQueryDTO listQueryDTO) {
        List<ResInfoDTO> dtoList = resInfoDao.queryListByCondition(listQueryDTO);
        return ResponseDTO.succData(dtoList);
    }

    /**
     * @author dl
     * @description 添加
     * @date 2021-10-28 16:26:17
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> add(ResInfoDTO addDTO) {
//        ResInfoEntity entity = BeanCopyUtil.copy(addDTO, ResInfoEntity.class);
        //resInfoDao.insert(entity);
        return ResponseDTO.succ();
    }


    /**
     * @author dl
     * @description 编辑
     * @date 2021-10-28 16:26:17
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> update(ResInfoDTO updateDTO) {
//        ResInfoEntity entity = BeanCopyUtil.copy(updateDTO, ResInfoEntity.class);
//        resInfoDao.updateById(entity);
        return ResponseDTO.succ();
    }


    /**
     * @author dl
     * @description 删除
     * @date 2021-10-28 16:26:17
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> delete(Long id) {
        resInfoDao.deleteById(id);
        return ResponseDTO.succ();
    }

    /**
     * @author dl
     * @description 根据ID查询
     * @date 2021-10-28 16:26:17
     */
    public ResponseDTO<ResInfoDTO> detail(Long id) {
//        ResInfoEntity entity = resInfoDao.selectById(id);
//        ResInfoDTO dto = BeanCopyUtil.copy(entity, ResInfoDTO.class);
        return ResponseDTO.succData(null);
    }

    /**
     * @author dl
     * @description 批量删除
     * @date 2021-10-28 16:26:17
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> deleteByIds(List<Long> ids) {
        resInfoDao.deleteByIds(ids);
        return ResponseDTO.succ();
    }


    /**
     * @author dl
     * @description 批量新增
     * @date 2021-10-28 16:26:17
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> addList(List<ResInfoDTO> addList) {
//        List<ResInfoEntity> entityList = BeanCopyUtil.copyList(addList, ResInfoEntity.class);
//        resInfoDao.insertBatch(entityList);
        return ResponseDTO.succ();
    }
}
